package com.thoughtworks.opensource.yui.dd.client;
/*
   Copyright 2006 C. K. Sidu Ponnappa

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.thoughtworks.opensource.yui.dd.client.helpers.Factory;
import com.thoughtworks.opensource.yui.dd.client.triads.constrainedgrid.ConstrainedGridView;
import com.thoughtworks.opensource.yui.dd.client.triads.incomingnumbers.IncomingNumbersModel;
import com.thoughtworks.opensource.yui.dd.client.triads.incomingnumbers.IncomingNumbersPanel;
import com.thoughtworks.opensource.yui.dd.client.windowresources.DisplayAreaViewBase;
import com.thoughtworks.opensource.yui.dd.client.windowresources.WidgetToDomainObjectMap;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Dd extends DisplayAreaViewBase implements EntryPoint {

    private IncomingNumbersModel incomingModel;

    public Dd() {
        super(RootPanel.get());
        widgetToObjectMap = new WidgetToDomainObjectMap();
    }

    private void createDynamicWidgets() {
        ConstrainedGridView grid = Factory.createDropAreaFlexTable("dropAreaGrid", "dropArea", this, controller);
        IncomingNumbersPanel leftPanelOne = Factory.createIncomingNumberPanel("leftPanelOne", "leftPanel", incomingModel, this, controller);
        IncomingNumbersPanel leftPanelTwo = Factory.createIncomingNumberPanel("leftPanelTwo", "leftPanel", incomingModel, this, controller);
        droppableAreas.add(grid);
        rootPanel.add(leftPanelOne);
        rootPanel.add(leftPanelTwo);
        rootPanel.add(grid);
    }

    /**
     * This is the entry point method.
     */
    public void onModuleLoad() {
        incomingModel = new IncomingNumbersModel();
        createDynamicWidgets();
    }

    public static String intToString(int number) {
        return number + "";
    }

}
